package com.mspbots.core.report.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.mspbots.core.DefaultBaseService;
import com.mspbots.core.report.model.HealthReportCount;
import com.mspbots.core.report.model.HealthReportDTO;
import com.mspbots.core.report.model.TenantHealthReportDetail;
import com.mspbots.core.report.model.User;
import com.mspbots.core.script.model.TenantScript;
import com.mspbots.core.wise.model.TenantConfiguration;
import com.mspbots.core.wise.model.TenantExceptionLog;
import com.mspbots.core.wise.model.TenantUser;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface HealthReportService extends DefaultBaseService<TenantHealthReportDetail> {


    IPage<TenantHealthReportDetail> listTenant(Page<TenantHealthReportDetail> page, HealthReportDTO query);

    TenantHealthReportDetail queryTenantHealth(Long tenantId);

    List<TenantHealthReportDetail> checkListTenant();

    Boolean tenantHealthCheck(TenantHealthReportDetail health);

    ObjectNode teamsSettingCheck(Long tenantId);

    ObjectNode connectWiseSettingCheck(Long tenantId);

    ObjectNode usersCheck(Long tenantId);

    ObjectNode botSettingCheck(Long tenantId);

    ObjectNode messageSettingCheck(Long tenantId);

    List<TenantConfiguration> selectTenantKeySetting(HealthReportDTO query);

    List<TenantExceptionLog> selectTenantAuthority(HealthReportDTO query);

    TenantExceptionLog selectLastSync(HealthReportDTO query);

    List<User> selectTenantAdmin(HealthReportDTO query);

    Integer selectCountTenantUserMapping(HealthReportDTO query);

    Integer selectCountTenantUser(HealthReportDTO query);

    List<TenantUser> selectTenantUserNotMapping(HealthReportDTO query);

    List<TenantUser> selectTenantUserNoManager(HealthReportDTO query);

    List<TenantUser> selectTenantUserNoWorkSchedule(HealthReportDTO query);

    List<TenantScript> selectTenantBot(HealthReportDTO query);

    Integer selectCountMessages(HealthReportDTO query);

    Integer selectCountMessagesOnReceived(HealthReportDTO query);

    Long listTenantCount(HealthReportDTO query);

    Integer selectCountUserNoReceived(HealthReportDTO query);

    Integer selectCountUserSendMessage(HealthReportDTO query);

    Integer selectCountUserHasReceived(HealthReportDTO query);

    List<HealthReportCount> selectCountBotMessages(HealthReportDTO query);

    TenantExceptionLog selectLastTeamsLog(HealthReportDTO query);

    @Transactional(rollbackFor = Exception.class)
    boolean saveOrUpdateHealth(TenantHealthReportDetail entity);
}
